# coding=utf-8

# 1.一行代码求1-100的和
# print(sum(range(0,101)))
# sum = 0
# for i in range(0,101):
#     sum+=i
# print(sum)

# 2.在函数内部修改全局变量
# b = 0
# def  func(a):
#     global b
#     b = 4
#     print(a+b)
#
# func(1)

# 3.python的5个标准库：os,re,sys,math,datatime,

# 4、字典键的删除和合并字典
# a = {"a":1,"b":2,"c":3}
# b = {"aa":11,"bb":22,"cc":33}
# a.pop("b")
# del a["a"]
# print(a)
# a.update(b)
# print(a)

# 6、实现列表去重,通过集合set去重
# a = [1,1,2,2,33,22]
# a = set(a)
# print(a)
#
# b = [x for x in a]
# print(b)

# 7、*args,**kwargs是什么意思
# 将不定数量的参数传给函数，*args元组参数,**kwargs键值对参数

# 10、python的内置数据类型有哪些：int,float,str,list,tuple,dict

# 11、__new__和__init__区别
# __init__是初始化方法，创建对象后，就会进行调用，可接收参数
# __new__需要一个参数cls,代表当前的类，需要有返回值

# 12、open,打开文件，进行读取和写入
# try:
#     f = open("../../requirement.txt")
#     print(f.readlines())
# except:
#     pass
# finally:
#     f.close()

# 13、列表[1,2,3,4,5],使用map()函数输出[1,4,5,16,25]，并用列表推导式提取大于10的数，最终输出[16,25]


# list1 = [1,2,3,4,5]
# def fn(b):
    # print(b*b)
    # return b*b
# fn(2)
# print(a)
# res = map(fn,list1)
# res1 = [ i for i in res ]
# print(res1)
# res2 = [ i for i in res if i > 10]
# print(res2)

# 14、random生成整数，小数，0-1的随机数
from functools import reduce

import numpy as np
# import random
#
# res1 = random.randint(0,10,)
# print(res1)
# print(np.random.randn(5))
# res3 = random.random()
# print(res3)

# 15、避免转义使用r,表示原始字符串，不转义特殊字符

# 16、正则表达式提取文本内容 、<div class="nam”>中国</div>，用正则匹配出标签里面的内容 (“中国”),其中class的类名不确定
# import re

# a = '<div class="nam”>中国</div>'
# res = re.findall(r'<div class=".*”>(.*?)</div>',a)
# print(res)

# 18、数据表student有id,name,score,city字段，其中name中的名字可有重复，需要消除重复行,请写sql语句
# selct distinct name from student

# 19、linux的常用命令
# cd ifconfig ping pwd vi cp mv tail ps netstat kill grep rm mkdir

# 21、列出python中可变数据类型和不可变数据类型，并简述原理
# 不可变的数据类型：数值型，字符串型，元组，不允许变的数据类型发生变化后，相当于新建一个对象，可以使用id查看对象的指向的地址
# a = 123
# b = 123
# print(id(a))
# print(id(b))
# a =1234
# print(id(a))
# 可变数据类型：字典，列表，对其修改，是改变变量的值，不是新建对象，变量引用的对象的值也不会发生改变
# 对于相同的值不同的对象，在内存中会存在不同的对象，每个对象都有自己的地址
# a = [1,2]
# print(id(a))
# a.append(3)
# print(id(a))
# b = [1,2]
# print(id(b))

# 22、s ="ajldjlajfdljfddd”，去重并从小到大排序输出"adfjl“
# s ="ajldjlajfdljfddd"
# res = set(s)
# res = list(res)
# res.sort(reverse=False)
# res = "".join(res)
# print(res)

# 23、用lambda函数实现两个数相乘
# sum = lambda a,b:a*b
# print(sum(5,4))

# 24、字典根据键从小到大排序
# dict={"name":"zs","age":18,"city":"深圳","tel":"1362626627"}
# res = sorted(dict.items(),key=lambda i:i[0],reverse=False)
# print(res)
# new_dict = {}
# for i in res:
#     new_dict[i[0]]=i[1]
# print(new_dict)

# 25、利用 collections 库的 Counter 方法统计字符串每单词出现的次数
# from collections import Counter

# a = "kjalfj;ldsjafl;hdsllfdhg;lahfbl;hl;ahlf;h"
# res = Counter(a)
# print(res)

# 28、求所有的基数
# a = [1,2,3,4,5,6,7,8,9,10]
# res = [i for i in a if i%2==1]
# print(res)

# 31、将列表合并
# a = [1,5,7,9]
# b = [2,2,6,8]
# a.extend(b)
# a.sort(reverse=False)
# print(a)

# 32、文件删除
# os.remove(文件名)
# rm -rf 文件名

# 33、时间戳
# import datetime
#
# a=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# print(a)

# 36、自定义抛出异常
# def fn():
#     try:
#         a =2
#         if a>1:
#             raise Exception("异常抛出")
#     except Exception as e:
#         print(e)
# fn()

# 37、正则表达式中，(.*)为贪婪模式，(.*?)为非贪婪模式

# 39、
# a= [[1,2],[3,4],[5,6]]
# res = [j for i in a for j in i]
# print(res)

# 42、python两个值的交换
# a = 1
# b = 2
# a,b=b,a
# print(a,b)

# 47、列表相加
# a = [1,5,7,9]
# b = [2,2,6,8]
# print(a+b)
# print(list(set(b)))

# 52、递归求取
# a = [3,23,41,22,1,0]
# b = []
# def get_min(list):
#     min_list = min(list)
#     list.remove(min_list)
#     b.append(min_list)
#     if len(list)>0:
#         get_min(list)
#     return b
# print(get_min(a))

# 54、保留两位小数
# a = 1.232
# print(round(float(a),2))

# 58、pop,del删除字典的键
# a ={"a":"11","b":"22"}
# a.pop("a")
# del a["b"]
# print(a)

# 85、字典和json字符串互相转换
# import json
#
# a ={"a":"11","b":"22"}
# b = json.dumps(a)
# print(b)
# print(type(b))
# c = json.loads(b)
# print(c)
# print(type(c))

# 统计字符的出现次数
# a = "aabbbccc"
# print(a.count("a"))

# 89、去除空格的方法
# a =" a b v"
# print(a.replace(" ",""))
# b = a.split(" ")
# print(b)
# c ="".join(b)
# print(c)

# a = int(input("输入数字："))
# print(a)




# a=int(input(),16)
# print(int(a))


# s = input("")
# s = "a b c"
# s = list(s)
# print(s)
# if 0<len(s)<10001:
#     for i in range(int(len(s)/2)):
#         # a = s[len(s)-i-1]
#         # s[len(s) - i - 1] = s[i]
#         # s[i] = a
#         s[i],s[len(s)-i-1] = s[len(s)-i-1],s[i]
#     print(s)
#     s="".join(s)
#     print(s)
# else:
#     print("字符串长度过长")

# x = 1
# y = 3
# x , y = y ,x
# print(x)
# print(y)
# c = int(input())
#
# a = 3
# b = 1
# if a/c==0 and b/c==0:
#     print(c)


# a = "aabbccc"
# for i in range(len(a)):
#     print(a[i])



# 列表推导式
list_b = [b for b in range(5) if b %2 == 1]
print(list_b)
# print(sorted([36, 5, 12, 9, 21]))

# 因为key是唯一的,所以最后value都是1
# dict_a = {key: value for key in 'python' for value in range(2)}
# print(dict_a)

# 可以根据键来构造值
# dict_b = {key: key * key for key in range(6)}
# print(dict_b)

# 遍历一个有键值关系的可迭代对象
# list_phone = [('HUAWEI', '华为'), ('MI', '小米'), ('OPPO', 'OPPO'), ('VIVO', 'VIVO')]
# dict_c = {key: value for key, value in list_phone}
# print(dict_c)

# def aa(x):
#     return x+x

# l = list(map(aa,[1,2,3]))
# print(l)

# def bb(x,y):
#     return x+y

# 累加
# l = reduce(bb,[i for i in range(101)])
# print(l)

# def cc(x):
#     if x %2 ==1:
#         return x

# l = list(filter(cc,[1,2,3,4]))
# print(l)


list_wz = ["百度","鲁诺布","淘宝"]

for i  in range(len(list_wz)):

    try:
        if list_wz[i] == "鲁诺布":
            print("中断")
        elif list_wz[i] =="淘宝" or list_wz[i] == "百度":
            print(list_wz[i]+"网站")
    except Exception as e:
        print("没有循环数据")
print("完成循环")

print("'''")

# for i in range(6):
#     for j in range()






